import type {
  CategoryPie,
  ChartsTrend,
  DailyData,
  FilterForm, MemberBarChartData,
  OverviewData,
  Records
} from "@/api/statistics/type.ts";
import type {SysResponse} from "@/api/commonType.ts";
import request from "@/utils/request.ts";

enum API {
  GET_OVERVIEW_DATA = '/api/statistics/overview/data',
  GET_OVERVIEW_DAILY_DATA = '/api/statistics/overview/daily',
  GET_OVERVIEW_RECORDS_DATA = '/api/statistics/overview/records',
  GET_CHART_TREND_MONTH_DATA = '/api/statistics/chart/trend/month',
  GET_CHART_TREND_DAY_DATA = '/api/statistics/chart/trend/day',
  GET_CHART_BAR_MEMBER_DATA = '/api/statistics/chart/bar/member',
  GET_CHART_PIE_CATEGORY_DATA = '/api/statistics/chart/pie/category'
}


/**
 * 获取总览数据
 * @param data
 */
export function getOverviewData(data: FilterForm) {
  return request.post<FilterForm, SysResponse<OverviewData>>(API.GET_OVERVIEW_DATA, data)
}

/**
 * 获取总览每日数据
 * @param data
 */
export function getOverviewDaily(data: FilterForm) {
  return request.post<FilterForm, SysResponse<DailyData>>(API.GET_OVERVIEW_DAILY_DATA, data)
}

/**
 * 获取总览记录数据
 * @param data
 */
export function getOverviewRecords(data: FilterForm) {
  return request.post<FilterForm, SysResponse<Records>>(API.GET_OVERVIEW_RECORDS_DATA, data)
}

/**
 * 获取图表-月趋势数据
 * @param data
 */
export function getChartTrendMonth(data: FilterForm) {
  return request.post<FilterForm, SysResponse<ChartsTrend[]>>(API.GET_CHART_TREND_MONTH_DATA, data)
}

/**
 * 获取图表-日趋势数据
 * @param data
 */
export function getChartTrendDay(data: FilterForm) {
  return request.post<FilterForm, SysResponse<ChartsTrend[]>>(API.GET_CHART_TREND_DAY_DATA, data)
}

/**
 * 获取图表-成员收支数据
 * @param data
 * @param type
 */
export function getChartBarMemberData(data: FilterForm, type: number) {
  return request.post<FilterForm, SysResponse<MemberBarChartData[]>>(API.GET_CHART_BAR_MEMBER_DATA + `/${type}`, data)
}

/**
 * 获取图表-分类收支数据
 * @param data
 * @param type
 */
export function getChartPieCategoryData(data: FilterForm, type: number) {
  return request.post<FilterForm, SysResponse<CategoryPie[]>>(API.GET_CHART_PIE_CATEGORY_DATA + `/${type}`, data)
}


